package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.service.IApCommentService;
import com.heima.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class ApCommentController {

    @Autowired
    private IApCommentService  apCommentService;

    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDto dto) {
        return apCommentService.save(dto);

    }
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto)
    {
        return apCommentService.load(dto);
    }


    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto )
    {
       long likes= apCommentService.like(dto);

        return ResponseResult.okResult(likes);
    }
}
